{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0,  1,  2,  3,  4],\n",
       "       [ 5,  6,  7,  8,  9],\n",
       "       [10, 11, 12, 13, 14]])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "a = np.arange(15).reshape(3, 5)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3, 5)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#the number of axes (dimensions) of the array\n",
    "a.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'int32'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.dtype.name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#the total number of elements of the array\n",
    "a.size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.,  0.,  0.,  0.],\n",
       "       [ 0.,  0.,  0.,  0.],\n",
       "       [ 0.,  0.,  0.,  0.]])"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.zeros ((3,4)) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[1, 1, 1, 1],\n",
       "        [1, 1, 1, 1],\n",
       "        [1, 1, 1, 1]],\n",
       "\n",
       "       [[1, 1, 1, 1],\n",
       "        [1, 1, 1, 1],\n",
       "        [1, 1, 1, 1]]])"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.ones( (2,3,4), dtype=np.int32 )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([10, 15, 20, 25])"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#To create sequences of numbers\n",
    "np.arange( 10, 30, 5 )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0. ,  0.3,  0.6,  0.9,  1.2,  1.5,  1.8])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.arange( 0, 2, 0.3 )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0,  1,  2],\n",
       "       [ 3,  4,  5],\n",
       "       [ 6,  7,  8],\n",
       "       [ 9, 10, 11]])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.arange(12).reshape(4,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.40130659,  0.45452825,  0.79776512],\n",
       "       [ 0.63220592,  0.74591134,  0.64130737]])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.random((2,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.        ,  0.06346652,  0.12693304,  0.19039955,  0.25386607,\n",
       "        0.31733259,  0.38079911,  0.44426563,  0.50773215,  0.57119866,\n",
       "        0.63466518,  0.6981317 ,  0.76159822,  0.82506474,  0.88853126,\n",
       "        0.95199777,  1.01546429,  1.07893081,  1.14239733,  1.20586385,\n",
       "        1.26933037,  1.33279688,  1.3962634 ,  1.45972992,  1.52319644,\n",
       "        1.58666296,  1.65012947,  1.71359599,  1.77706251,  1.84052903,\n",
       "        1.90399555,  1.96746207,  2.03092858,  2.0943951 ,  2.15786162,\n",
       "        2.22132814,  2.28479466,  2.34826118,  2.41172769,  2.47519421,\n",
       "        2.53866073,  2.60212725,  2.66559377,  2.72906028,  2.7925268 ,\n",
       "        2.85599332,  2.91945984,  2.98292636,  3.04639288,  3.10985939,\n",
       "        3.17332591,  3.23679243,  3.30025895,  3.36372547,  3.42719199,\n",
       "        3.4906585 ,  3.55412502,  3.61759154,  3.68105806,  3.74452458,\n",
       "        3.8079911 ,  3.87145761,  3.93492413,  3.99839065,  4.06185717,\n",
       "        4.12532369,  4.1887902 ,  4.25225672,  4.31572324,  4.37918976,\n",
       "        4.44265628,  4.5061228 ,  4.56958931,  4.63305583,  4.69652235,\n",
       "        4.75998887,  4.82345539,  4.88692191,  4.95038842,  5.01385494,\n",
       "        5.07732146,  5.14078798,  5.2042545 ,  5.26772102,  5.33118753,\n",
       "        5.39465405,  5.45812057,  5.52158709,  5.58505361,  5.64852012,\n",
       "        5.71198664,  5.77545316,  5.83891968,  5.9023862 ,  5.96585272,\n",
       "        6.02931923,  6.09278575,  6.15625227,  6.21971879,  6.28318531])"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from numpy import pi\n",
    "np.linspace( 0, 2*pi, 100 )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([  0.00000000e+00,   6.34239197e-02,   1.26592454e-01,\n",
       "         1.89251244e-01,   2.51147987e-01,   3.12033446e-01,\n",
       "         3.71662456e-01,   4.29794912e-01,   4.86196736e-01,\n",
       "         5.40640817e-01,   5.92907929e-01,   6.42787610e-01,\n",
       "         6.90079011e-01,   7.34591709e-01,   7.76146464e-01,\n",
       "         8.14575952e-01,   8.49725430e-01,   8.81453363e-01,\n",
       "         9.09631995e-01,   9.34147860e-01,   9.54902241e-01,\n",
       "         9.71811568e-01,   9.84807753e-01,   9.93838464e-01,\n",
       "         9.98867339e-01,   9.99874128e-01,   9.96854776e-01,\n",
       "         9.89821442e-01,   9.78802446e-01,   9.63842159e-01,\n",
       "         9.45000819e-01,   9.22354294e-01,   8.95993774e-01,\n",
       "         8.66025404e-01,   8.32569855e-01,   7.95761841e-01,\n",
       "         7.55749574e-01,   7.12694171e-01,   6.66769001e-01,\n",
       "         6.18158986e-01,   5.67059864e-01,   5.13677392e-01,\n",
       "         4.58226522e-01,   4.00930535e-01,   3.42020143e-01,\n",
       "         2.81732557e-01,   2.20310533e-01,   1.58001396e-01,\n",
       "         9.50560433e-02,   3.17279335e-02,  -3.17279335e-02,\n",
       "        -9.50560433e-02,  -1.58001396e-01,  -2.20310533e-01,\n",
       "        -2.81732557e-01,  -3.42020143e-01,  -4.00930535e-01,\n",
       "        -4.58226522e-01,  -5.13677392e-01,  -5.67059864e-01,\n",
       "        -6.18158986e-01,  -6.66769001e-01,  -7.12694171e-01,\n",
       "        -7.55749574e-01,  -7.95761841e-01,  -8.32569855e-01,\n",
       "        -8.66025404e-01,  -8.95993774e-01,  -9.22354294e-01,\n",
       "        -9.45000819e-01,  -9.63842159e-01,  -9.78802446e-01,\n",
       "        -9.89821442e-01,  -9.96854776e-01,  -9.99874128e-01,\n",
       "        -9.98867339e-01,  -9.93838464e-01,  -9.84807753e-01,\n",
       "        -9.71811568e-01,  -9.54902241e-01,  -9.34147860e-01,\n",
       "        -9.09631995e-01,  -8.81453363e-01,  -8.49725430e-01,\n",
       "        -8.14575952e-01,  -7.76146464e-01,  -7.34591709e-01,\n",
       "        -6.90079011e-01,  -6.42787610e-01,  -5.92907929e-01,\n",
       "        -5.40640817e-01,  -4.86196736e-01,  -4.29794912e-01,\n",
       "        -3.71662456e-01,  -3.12033446e-01,  -2.51147987e-01,\n",
       "        -1.89251244e-01,  -1.26592454e-01,  -6.34239197e-02,\n",
       "        -2.44929360e-16])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sin(np.linspace( 0, 2*pi, 100 ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ True  True False False]\n"
     ]
    }
   ],
   "source": [
    "#the product operator * operates elementwise in NumPy arrays\n",
    "a = np.array( [20,30,40,50] )\n",
    "b = np.arange( 4 )\n",
    "#print a \n",
    "#print b\n",
    "#b\n",
    "c = a-b\n",
    "#print c\n",
    "b**2\n",
    "#print b**2\n",
    "print a<35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1 1]\n",
      " [0 1]]\n",
      "[[2 0]\n",
      " [3 4]]\n",
      "[[5 4]\n",
      " [3 4]]\n",
      "[[5 4]\n",
      " [3 4]]\n"
     ]
    }
   ],
   "source": [
    "#The matrix product can be performed using the dot function or method\n",
    "A = np.array( [[1,1],\n",
    "               [0,1]] )\n",
    "B = np.array( [[2,0],\n",
    "               [3,4]] )\n",
    "print A\n",
    "print B\n",
    "#print A*B\n",
    "print A.dot(B)\n",
    "print np.dot(A, B) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
